﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Freebie
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            checkBox1.Checked = CRSettings.myPrefs.HaveSavageryGlyph;
            checkBox2.Checked = CRSettings.myPrefs.useLifeblood;
            checkBox3.Checked = CRSettings.myPrefs.alchemyflask;
            checkBox4.Checked = CRSettings.myPrefs.Movement;
            checkBox5.Checked = CRSettings.myPrefs.Facing;
            checkBox6.Checked = CRSettings.myPrefs.Targeting;

            comboBox1.SelectedIndex = CRSettings.myPrefs.useBerserk;
            comboBox2.SelectedIndex = CRSettings.myPrefs.trinket1;
            comboBox3.SelectedIndex = CRSettings.myPrefs.trinket2;
            comboBox4.SelectedIndex = CRSettings.myPrefs.engigloves;
            comboBox5.SelectedIndex = CRSettings.myPrefs.useBerserking;
            comboBox6.SelectedIndex = CRSettings.myPrefs.virmenpotion;
            comboBox7.SelectedIndex = CRSettings.myPrefs.agilityflask;
            comboBox8.SelectedIndex = CRSettings.myPrefs.useFeralSpirit;

            numericUpDown1.Value = new decimal(CRSettings.myPrefs.CenarionWardPercent);
            numericUpDown2.Value = new decimal(CRSettings.myPrefs.healthstonepercent);
            numericUpDown3.Value = new decimal(CRSettings.myPrefs.BarskinPercent);
            numericUpDown4.Value = new decimal(CRSettings.myPrefs.SurvivalInstinctsPercent);
            numericUpDown5.Value = new decimal(CRSettings.myPrefs.FrenziedRegenerationPercent);
            numericUpDown6.Value = new decimal(CRSettings.myPrefs.startBearAoe);
            numericUpDown7.Value = new decimal(CRSettings.myPrefs.startCatAoe);
            numericUpDown8.Value = new decimal(CRSettings.myPrefs.RenewalPercent);
            numericUpDown9.Value = new decimal(CRSettings.myPrefs.HealingTouchPercent);


            comboBoxPauseKey.SelectedIndex = CRSettings.myPrefs.PauseKey;
            switch (CRSettings.myPrefs.PauseKey)
            {
                case 0:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.None;
                    break;
                case 1:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.LSHIFT;
                    break;
                case 2:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.RSHIFT;
                    break;
                case 3:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.LCTRL;
                    break;
                case 4:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.RCTRL;
                    break;
                case 5:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.LALT;
                    break;
                case 6:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.RALT;
                    break;
            }

            comboBoxAoePauseKey.SelectedIndex = CRSettings.myPrefs.AoePauseKey;
            switch (CRSettings.myPrefs.AoePauseKey)
            {
                case 0:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.None;
                    break;
                case 1:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.LSHIFT;
                    break;
                case 2:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.RSHIFT;
                    break;
                case 3:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.LCTRL;
                    break;
                case 4:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.RCTRL;
                    break;
                case 5:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.LALT;
                    break;
                case 6:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.RALT;
                    break;
            }

            comboBoxBearFormKey.SelectedIndex = CRSettings.myPrefs.BearFormKey;
            switch (CRSettings.myPrefs.BearFormKey)
            {
                case 0:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.None;
                    break;
                case 1:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.LSHIFT;
                    break;
                case 2:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.RSHIFT;
                    break;
                case 3:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.LCTRL;
                    break;
                case 4:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.RCTRL;
                    break;
                case 5:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.LALT;
                    break;
                case 6:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.RALT;
                    break;
            }


        }

        private void button1_Click(object sender, EventArgs e)
        {
            CRSettings.myPrefs.Save();
            Close();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.HaveSavageryGlyph = checkBox1.Checked;
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.useBerserk = comboBox1.SelectedIndex;
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.useLifeblood = checkBox2.Checked;
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.CenarionWardPercent = (int)numericUpDown1.Value;
        }

        private void numericUpDown2_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.healthstonepercent = (int)numericUpDown2.Value;
        }

        private void numericUpDown3_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.BarskinPercent = (int)numericUpDown3.Value;
        }

        private void numericUpDown4_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.SurvivalInstinctsPercent = (int)numericUpDown4.Value;
        }

        private void numericUpDown5_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.FrenziedRegenerationPercent = (int)numericUpDown5.Value;
        }

        private void numericUpDown6_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.startBearAoe = (int)numericUpDown6.Value;
        }

        private void numericUpDown7_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.startCatAoe = (int)numericUpDown7.Value;
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.trinket1 = comboBox2.SelectedIndex;
        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.trinket2 = comboBox3.SelectedIndex;
        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.engigloves = comboBox4.SelectedIndex;
        }

        private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.useBerserking = comboBox5.SelectedIndex;
        }

        private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.alchemyflask = checkBox3.Checked;
        }

        private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.virmenpotion = comboBox6.SelectedIndex;
        }

        private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.agilityflask = comboBox7.SelectedIndex;
        }

        private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.useFeralSpirit = comboBox8.SelectedIndex;
        }

        private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.Movement = checkBox4.Checked;
        }

        private void checkBox5_CheckedChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.Facing = checkBox5.Checked;
        }

        private void checkBox6_CheckedChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.Targeting = checkBox6.Checked;
        }

        private void comboBoxPauseKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.PauseKey = comboBoxPauseKey.SelectedIndex;
            switch (comboBoxPauseKey.SelectedIndex)
            {
                case 0:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.None;
                    break;
                case 1:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.LSHIFT;
                    break;
                case 2:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.RSHIFT;
                    break;
                case 3:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.LCTRL;
                    break;
                case 4:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.RCTRL;
                    break;
                case 5:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.LALT;
                    break;
                case 6:
                    CRSettings.myPrefs.PauseKeys = CRSettings.Keypress.RALT;
                    break;
            }
        }

        private void comboBoxBearFormKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.BearFormKey = comboBoxBearFormKey.SelectedIndex;
            switch (comboBoxBearFormKey.SelectedIndex)
            {
                case 0:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.None;
                    break;
                case 1:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.LSHIFT;
                    break;
                case 2:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.RSHIFT;
                    break;
                case 3:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.LCTRL;
                    break;
                case 4:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.RCTRL;
                    break;
                case 5:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.LALT;
                    break;
                case 6:
                    CRSettings.myPrefs.BearFormKeys = CRSettings.Keypress.RALT;
                    break;
            }
        }

        private void comboBoxAoePauseKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.AoePauseKey = comboBoxAoePauseKey.SelectedIndex;
            switch (comboBoxAoePauseKey.SelectedIndex)
            {
                case 0:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.None;
                    break;
                case 1:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.LSHIFT;
                    break;
                case 2:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.RSHIFT;
                    break;
                case 3:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.LCTRL;
                    break;
                case 4:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.RCTRL;
                    break;
                case 5:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.LALT;
                    break;
                case 6:
                    CRSettings.myPrefs.AoePauseKeys = CRSettings.Keypress.RALT;
                    break;
            }
        }

        private void numericUpDown9_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.HealingTouchPercent = (int)numericUpDown9.Value;
        }

        private void numericUpDown8_ValueChanged(object sender, EventArgs e)
        {
            CRSettings.myPrefs.RenewalPercent = (int)numericUpDown8.Value;
        }
    }
}
